Various tweaks to redesigned structures#963
Conversation
`TxGraph::try_get_chain_position` used to always exclude unconfirmed transactions with last_seen value of 0. However, what is the point of including a transaction in the graph if it cannot be part of the chain history? Additionally, maybe sometimes we don't wish to use the last_seen field at all. The new behavior will consider unconfirmed transactions with last_seen of 0.
LLFourn
left a comment
There was a problem hiding this comment.
I left some comments. Other misc things I noticed that are not changed in this PR but could be:
LocalChain::get_block(height) -> BlockIdallows for invalid representation. It should beget_block_hash(height) -> BlockHash.- It would be nice if
LocalChainhad a way to doing.blocksand just getting a reference to the inner BTreeMap without using theAsRefimplementation. - There are all these
TODOsas doc comments for Local chain. Can you make issues out of the TODOs and remove them from comments.
If `BlockId` implements `Anchor`, the meaning is ambiguous. We cannot tell whether it means the tx is anchors at the block, or whether it also means the tx is confirmed at that block. Instead, `ConfirmationHeightAnchor` and `ConfirmationTimeAnchor` structs are introduced as non-ambiguous `Anchor` implementations. Additionally, `TxGraph::relevant_heights` is removed because it is also ambiguous. What heights are deemed relevant? A simpler and more flexible method `TxGraph::all_anchors` is introduced instead.
8de421f to
2ccc116
Compare
* Introduce `LocalChain::inner` method to get the inner map of block height to hash. * Replace `LocalChain::get_block` (which outputted `BlockId`, thus able to return invalid representation) with `get_blockhash` that just returns a `BlockHash`. * Remove `TODO` comments that should be github tickets.
danielabrozzoni
left a comment
There was a problem hiding this comment.
ACK a56d289
A few comments but they don't have to be addressed
| } | ||
|
|
||
| impl<A: Anchor, I: Indexer> IndexedTxGraph<A, I> { | ||
| impl<A, I> IndexedTxGraph<A, I> { |
There was a problem hiding this comment.
I'm not sure how idiomatic this is, since we always end up using IndexedTxGraph with A: Anchor, I: Indexer, but I'm not opposed to this change if it's useful for us somehow
There was a problem hiding this comment.
Even if it's not useful directly, it may allow building logic around/above it not require as many generic constraints. I would leave it as is unless if there are downsides to this?
|
After a call with @LLFourn, the follow things will be added (either to this PR, or a separate PR):
|
LLFourn
left a comment
There was a problem hiding this comment.
Left another idea. Approved. Happy to merge when @evanlinjin is happy.
Also, we can get rid of `LocalChain::get_blockhash`, since we can already expose the internal map. Additionally, tests and docs are improved.
Description
The following tweaks are made:
TxGraph::try_get_chain_positionused to always exclude unconfirmed transactions with last_seen value of 0. However, what is the point of including a transaction in the graph if it cannot be part of the chain history? Additionally, maybe sometimes we don't wish to use the last_seen field at all. The new behavior will consider unconfirmed transactions with last_seen of 0.LocalChain::insert_block. This is necessary as aLocalChainis updated with anotherLocalChain. The updateLocalChainneeds a simple way to insert blocks.BlockIdshould not implementAnchor. Discussion: Introduce redesignedbdk_chainstructures #926 (comment).TxGraph::relevant_heightsas it is ambiguous. A simpler and more flexible alternative methodTxGraph::all_anchorsis introduced.Changelog notice
Checklists
All Submissions:
cargo fmtandcargo clippybefore committingNew Features: